package downloader

import (
	"github.com/EDDYCJY/fake-useragent"
	"github.com/axgle/mahonia"
	"github.com/gookit/color"
	"io"
	"net/http"
)

func Get(url string) io.Reader {

	client := &http.Client{}
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		color.Error.Println("http.NewRequest err: %v", err)
	}

	req.Header.Add("User-Agent", browser.Random())
	req.Header.Add("Referer", "https://car.autohome.com.cn")

	resp, err := client.Do(req)
	if err != nil {
		color.Error.Println("client.Do err: %v", err)
	}

	mah := mahonia.NewDecoder("gbk")
	return mah.NewReader(resp.Body)

}
